import { reactive } from 'vue';

const eventBus = reactive({
  audio: null,
});

const playAudio = (src) => {
  if (eventBus.audio) {
    eventBus.audio.pause();
    eventBus.audio.currentTime = 0;
  }
  eventBus.audio = new Audio(src);
  eventBus.audio.play();
};

export { eventBus, playAudio };